<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <style>
        html,
        body {
            font-size: 14px;
            height: 100%;
            background-color: #f2f2f2;
        }

        .bluecolor {
            color: #2E7AFA;
        }

        .orangecolor {
            color: #FEA82F;
        }

        header {
            height: 75px;
            position: fixed;
            top: 0;
            width: 100%;
            height: 75px;
            text-align: left;
            background-color: #FBB40E;
            border-bottom: 1px solid #fff;
            z-index: 999;
        }

        header .head {
            position: relative;
            margin-top: 38px;
            text-align: center;
        }

        .head .city {
            position: absolute;
            top: 0;
            left: 5px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            height: 100%;
            width: 17%;
            padding-left: 0.5rem;
            box-sizing: border-box;
            color: #fff;
        }

        .head .city img {
            width: 1.2rem;
            height: 1.2rem;
            margin-right: 0.2rem;
        }

        .head .city span {
            font-size: 1.1rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .head .search {
            width: 65%;
            padding: 0.5rem;
            padding-left: 3rem;
            margin-left: 2rem;
            box-sizing: border-box;
            background: url(../image/icon/search.png)no-repeat center;
            background-size: 1.2rem 1.2rem;
            background-position-x: 0.7rem;
            background-color: #fff;
            border-radius: 0.5rem;
        }

        main {
            padding-top: 85px;
        }

        .bannercontainer {
            width: 95%;
            margin: auto;
            height: 10rem;
        }

        .bannercontainer .swiper-slide {
            padding: 0 0.1rem;
            box-sizing: border-box;
        }

        .bannercontainer .swiper-slide img {
            width: 100%;
            height: 100%;
            border-radius: 0.5rem;
        }

        .partnavbox {
            width: 95%;
            margin: auto;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            margin-top: 0.5rem;
            margin-bottom: 0.5rem;
        }

        .partnavbox img {
            width: 3rem;
            height: 3rem;
            vertical-align: middle;
        }

        .partnav {
            width: 48%;
            padding: 0.5rem;
            box-sizing: border-box;
            border-radius: 0.35rem;
            background-color: #fff;
            box-shadow: 0 0 3px #989898;
        }

        .partnav div {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .partnav div:nth-child(2) {
            color: #678;
            font-weight: 400;
        }

        .partnav span {
            margin-left: 0.5rem;
            font-size: 1.1rem;
            font-weight: 500;
        }

        .intership {
            margin-bottom: 0.5rem;
        }

        .famousrecruit {
            margin-bottom: 0.5rem;
        }

        .reminder {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            padding: 0.3rem 0;
            width: 95%;
            margin: 0.2rem auto;
            background-color: #fff;
            border-radius: 0.35rem;
        }

        .reminder img {
            margin: 0 0.5rem;
            width: 28px;
            height: 25px;
        }

        .reminder .tgcontainer {
            width: 80%;
            height: 2rem;
            margin: 0;
        }

        .reminder .tgcontainer .swiper-slide {
            height: 2rem;
            line-height: 2rem;
            text-align: left;
            color: orange;
        }

        .infolist {
            margin-top: 0.5rem;
        }

        .infolist-title {
            width: 40%;
            padding: 0.3rem;
            box-sizing: border-box;
            font-size: 1rem;
            margin-left: 0.5rem;
            text-align: center;
            color: #fff;
            background-image: linear-gradient(to right, #ffe985 0%, #fa742b 100%);
            border-radius: 0.35rem;
        }

        .infolist-content {
            margin-top: 0.5rem;
        }

        .infolist-content li {
            padding: 0.3rem 1rem 0.5rem;
            border-bottom: 1px solid #f2f2f2;
            background-color: #fff;
        }

        .infolist-content li div {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.3rem;
        }

        .jobname span:nth-child(1) {
            width: 80%;
            color: #333;
            font-size: 1.1rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .jobcompany {
            color: #989898;
            font-size: 1rem;
        }

        .jobcompany img {
            width: 1.5rem;
            height: 1.5rem;
            margin-right: 0.5rem;
        }

        .jobaddress .length span {
            font-size: 1rem;
            color: #FFBF78;
            padding: 0.1rem;
            border: 1px solid #FFBF78;
            border-radius: 0.35rem;
            margin-right: 0.5rem;
        }

        .jobaddress .readcount {
            color: #2E7AFA;
        }

        .readcount img {
            width: 1.5rem;
            height: 1.5rem;
            margin-right: 0.3rem;
        }

        footer {
            padding: 0.5rem;
            color: #989898;
            font-size: 0.8rem;
            text-align: center;
        }
    </style>
</head>

<body>
    <header>
        <div class="head">
            <div class="city" onclick="choosecity()">
                <img src="../image/icon/position@3x.png" alt="">
                <span>成都</span>
            </div>
            <input type="text" class="search" value="" placeholder="成都都在搜：实习">
        </div>
    </header>
    <main>
        <div class="swiper-container bannercontainer">
            <div class="swiper-wrapper swiper-wrapper1">

            </div>
        </div>
        <div class="partnavbox">
            <div class="partnav intership" page-address="parttimetype.html">
                <div>
                    <span>实习</span>
                    <img src="../image/Internship@3x.png" alt="">
                </div>
                <div>海量实习生岗位等你来投</div>
            </div>
            <div class="partnav famousrecruit" page-address="parttimetype.html">
                <div>
                    <span>优质企业</span>
                    <img src="../image/famousrecruit@3x.png" alt="">
                </div>
                <div>优质企业任你选</div>
            </div>
            <div class="partnav hotjob" page-address="parttimetype.html">
                <div>
                    <span>热门</span>
                    <img src="../image/findjob@3x.png" alt="">
                </div>
                <div>更多热门岗位点这里</div>
            </div>
            <div class="partnav easywork" page-address="parttimetype.html">
                <div>
                    <span>易上手</span>
                    <img src="../image/shakered@3x.png" alt="">
                </div>
                <div>超简单，马上上手赚钱</div>
            </div>
        </div>
        <div class="reminder">
            <img src="../image/icon/lb.png" alt="">
            <div class="swiper-container tgcontainer">
                <div class="swiper-wrapper swiper-wrapper2">
                    <div class="swiper-slide">平台将重拳出击刷单和扰乱平台正常秩序行为</div>
                    <div class="swiper-slide">高薪不轻信，求职莫大意</div>
                    <div class="swiper-slide">2020年我国将全面步入小康社会</div>
                    <div class="swiper-slide">一大批知名企业即将入驻本平台</div>
                    <div class="swiper-slide">年后大波好工作即将袭来，你准备好了吗？</div>
                </div>
            </div>
        </div>
        <div class="infolist">
            <div class="infolist-title">---优质兼职推荐---</div>
            <ul class="infolist-content">

            </ul>
        </div>
    </main>
    <footer>--没有更多数据了--</footer>
</body>
<script type="text/template" id="banner">
    {{~it.items:value:index}}
    <div class="swiper-slide" data-type="{{=value.type}}">
        <img src="{{=value.imgsrc}}" alt="">
        <span style="display:none">{{=value.type}}</span>
    </div>
    {{~}}
</script>
<script type="text/template" id="job">
    {{~it.items:value:index}}
    <li data-id="{{=value.id}}" data-num="{{=value.readcount}}">
        <div class="jobname">
            <span>{{=value.jobname}}</span>
            <span style="color:#FEA82F">{{=value.salary}}</span>
        </div>
        <div class="jobcompany" style="color:#989898">
            <div>
                <img src="../image/icon/company.png" alt="">
                <span>{{=value.company}}</span>
            </div>
            <span>{{=value.address}}</span>
        </div>
        <div class="jobaddress" style="color:#989898">
            <div class="length">
                {{? value.paytype}}
                <span>{{=value.paytype}}</span> {{??}}
                <i></i> {{?}} {{? value.cyclelength}}
                <span>{{=value.cyclelength}}</span> {{??}}
                <i></i> {{?}} {{? value.type}}
                <span>{{=value.type}}</span> {{??}}
                <i></i> {{?}} {{? value.description}}
                <span>{{=value.description}}</span> {{??}}
                <i></i> {{?}}
            </div>
            <div class="readcount">
                <img src="../image/icon/hot.png" alt="">
                <span id="number">{{=value.readcount}}</span>
            </div>
        </div>
    </li>
    {{~}}
</script>
<script src="../script/jquery-1.11.3.min.js" charset="utf-8"></script>
<script src="../script/api.js" charset="utf-8"></script>
<script src="../script/doT.min.js" charset="utf-8"></script>
<script src="../script/swiper.min.js" charset="utf-8"></script>
<script type="text/javascript">
    apiready = function() {
        api.addEventListener({
            name: 'viewappear'
        }, function(ret, err) {
            if ($api.getStorage('city')) {
                $('.city span').text($api.getStorage('city'));
            } else {
                $('.city span').text('成都');
            }
        });
        getShufflingfigure();
        getJob();
        api.addEventListener({
            name: 'myEvent'
        }, function(ret, err) {
            if (ret) {
                getShufflingfigure();
            }
        });

        var myNoticeSwiper = new Swiper('.tgcontainer', {
            direction: 'vertical',
            loop: true,
            autoplay: true,
            spaceBetween: 0,
            effect: 'slide',
        });

    }

    function choosecity() {
        api.openWin({
            name: 'city',
            url: './city.html',
            pageParam: {}
        });
    }

    $('.search').click(function() {
        api.openWin({
            name: 'search',
            url: './search.html',
            pageParam: {}
        });
    })

    function getShufflingfigure() {
        api.ajax({
            url: 'http://122.112.138.133/wangt/jianzhi/queryLunBo.com',
            method: 'post',
            data: {
                body: {}
            }
        }, function(ret, err) {
            if (ret) {
                $('.swiper-wrapper1').append(parttime_render('banner', ret.data.records));
                setTimeout(function() {
                    api.removeLaunchView();
                    api.closeFrame({
                        name: 'readnull'
                    });
                }, 2000)
                var mySwiper = new Swiper('.bannercontainer', {
                    direction: 'horizontal',
                    loop: true,
                    autoplay: true,
                })
                $('.swiper-slide').click(function() {
                    api.openWin({
                        name: 'parttimetype',
                        url: './parttimetype.html',
                        pageParam: {
                            title: $(this).attr('data-type')
                        }
                    });
                })
            } else {
                api.removeLaunchView();
                api.openFrame({
                    name: 'readnull',
                    url: './readnull.html',
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0)',

                });
            }
        });

    }

    $(".partnav").click(function() {
        var page_path = $(this).attr("page-address");
        if (page_path) {
            api.openWin({
                name: page_path.split(".")[0],
                url: page_path,
                bounces: false,
                pageParam: {
                    title: $(this).find('span').text()
                }
            })
        }
    })

    function getJob() {
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            modal: false
        });
        api.ajax({
            url: 'http://122.112.138.133/wangt/jianzhi/queryHotJob.com',
            method: 'post',
            data: {
                body: {}
            }
        }, function(ret, err) {
            if (ret) {
                $('.infolist-content').append(parttime_render('job', ret.data.records));
                api.hideProgress();
                $('.infolist-content li').click(function() {
                    var num = Number($(this).attr('data-num')) + 1;
                    $(this).find('#number').text(num);
                    $(this).attr('data-num', num);
                    var id = $(this).attr('data-id');
                    api.ajax({
                        url: 'http://122.112.138.133/wangt/jianzhi/updateReadCount.com',
                        method: 'post',
                        data: {
                            body: {
                                'tbname': 'jobinfo',
                                'id': id,
                                'readcount': num
                            }
                        }
                    }, function(ret, err) {
                        if (ret) {}
                    });
                    api.openWin({
                        name: 'jobdetails',
                        url: './jobdetails.html',
                        pageParam: {
                            id: $(this).attr('data-id')
                        }
                    })
                })
            }
        });
    }

    function parttime_render(id, elements, options) {
        var options = options || {};
        var elementObj = doT.template($api.byId(id).innerHTML);
        var elementData = $.extend({
            items: elements
        }, options);
        return elementObj(elementData);
    }
</script>

</html>
